package com.lingx.web.api.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.lingx.bean.TokenBean;
import com.lingx.service.UserService;
import com.lingx.utils.TokenUtils;
import com.lingx.web.api.IApi;
@Component
public class Api8017 extends AbstractAuthApi implements IApi{

	@Resource
	private JdbcTemplate jdbcTemplate;
	@Resource
	private UserService userService;
	@Override
	public int getApiCode() {
		return 8017;
	}
	@Override
	public String getApiName() {
		return "获取当前用户信息";
	}
	@Override
	public Map<String, Object> api(Map<String, Object> params) {
		Map<String,Object> ret=IApi.getRetMap(1, "操作成功");
		String token=IApi.getParamString(params, "lingxtoken", "");
		TokenBean bean=TokenUtils.getTokenData(token);
		Map<String,Object> data=new HashMap<>();
		data.put("account", bean.getAccount());
		data.put("userId", bean.getUserId());
		data.put("userName", bean.getUserName());
		data.put("roleCode", this.userService.getRoleCodeByUserId(bean.getUserId()));
		ret.put("data", data);
		return ret;
	}
	public boolean isLog() {
		return false;
	}
}
